﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:viewModel="clr-namespace:EcoProIT.UserControles.ViewModel"
             xmlns:view="clr-namespace:EcoProIT.UserControles.View" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d"
             x:Class="EcoProIT.UserControles.View.ProcessBasicDef" d:DesignHeight="500"
           d:DesignWidth="633" Padding="0">
    <UserControl.Resources>
        <viewModel:ResourceDefinitionModel x:Key="Object1" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="110" />
            <RowDefinition Height="203" />
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="89" />
            <ColumnDefinition />

        </Grid.ColumnDefinitions>
        <Label Content="Job" HorizontalAlignment="Left" Margin="48,10,0,0"  VerticalAlignment="Top" Height="26" Width="28" />
        <Label Content="Sub Jobs" HorizontalAlignment="Left" Grid.Row="1" 
               VerticalAlignment="Top" Margin="10,26,0,0" Height="26" Width="57" />
        <DataGrid CanUserAddRows="False" Grid.ColumnSpan="2" Margin="10,49,10,4"
                  SelectedValue="{Binding SelectedSubJob, Mode=OneWayToSource}" ItemsSource="{Binding SelectedSubJobs}" HorizontalScrollBarVisibility="Disabled"
                  Grid.Row="1" AutoGenerateColumns="False" >
            <DataGrid.Columns>
                <DataGridTemplateColumn MinWidth="18" Header="Remove">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Delete"
                                    Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                                    CommandParameter="{Binding}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Header="Distribution" Binding="{Binding Distribution.ShowParameters, Mode=OneWay}"
                                    CanUserReorder="True" />
                <DataGridTextColumn Header="Unit"
                                    Binding="{Binding Distribution.ParameterConverter.UnitType, Mode=OneWay}"
                                    CanUserReorder="True" />
                <DataGridTextColumn Header="Description" MaxWidth="250" CanUserReorder="True">
                    <DataGridTextColumn.CellStyle>
                        <Style TargetType="{x:Type DataGridCell}">
                            <Setter Property="ContentTemplate">
                                <Setter.Value>
                                    <DataTemplate>
                                        <TextBlock TextWrapping="Wrap" Text="{Binding Description, Mode=OneWay}"/>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </DataGridTextColumn.CellStyle>
                </DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>

        <ComboBox SelectedIndex="1" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="150" Margin="0,10,0,0"
                  ItemsSource="{Binding Job}" SelectedValue="{Binding SelectedJob}" DisplayMemberPath="Name" 
                  Width="150" Grid.Column="1" />
        <TextBox Grid.Column="1" HorizontalAlignment="Left" Margin="308,8,0,0" TextWrapping="Wrap" Text="{Binding SelectedJob.Name, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="101"/>

        <Button Content="Add New Sub Job"  VerticalAlignment="Top" Grid.Column="1" Margin="0,4,40,0"
                Command="{Binding AddSubJobClickAction}" Grid.Row="1"  HorizontalAlignment="Right" Width="100"  />
        <Label Content="New sub job" HorizontalAlignment="Left" Margin="6,0,0,7"  VerticalAlignment="Bottom"  Width="76" />
        <Label Content="Description" Margin="12,0,0,0" VerticalAlignment="Top"
                Grid.Row="1" RenderTransformOrigin="-1.286,0.423" HorizontalAlignment="Left" Width="70"  />
        <TextBox Grid.Column="1"  Margin="10,4,149,0" TextWrapping="Wrap"
                 Text="{Binding SelectedSubJob.Description, UpdateSourceTrigger=PropertyChanged}"
                 VerticalAlignment="Top" Grid.Row="1" />
        <view:DistributionView
            HasDistribution="{Binding DataContext.SelectedSubJob, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type view:ProcessBasicDef}}}"
            Grid.Column="1" Margin="4,0,0,10" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="500"/>
        <Label Content="MTBF" HorizontalAlignment="Left" Margin="7,5,0,0" Width="71" Grid.Row="2"  VerticalAlignment="Top"  />
        <view:DistributionView HasDistribution="{Binding DataContext.MTBF, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type view:ProcessBasicDef}}}"
                                Grid.ColumnSpan="2" Margin="6,28,0,0" Grid.Row="2"
                                VerticalAlignment="Top" Width="623" Height="23" HorizontalAlignment="Left" />
        <Label Content="MTTR"   HorizontalAlignment="Left" Margin="7,56,0,0" Width="69" Grid.Row="2"  VerticalAlignment="Top" RenderTransformOrigin="0.594,0.444" />
        <view:DistributionView HasDistribution="{Binding DataContext.MTTR, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type view:ProcessBasicDef}}}"
                                Grid.ColumnSpan="2" Margin="6,78,0,0" Grid.Row="2" VerticalAlignment="Top" Width="623"  HorizontalAlignment="Left" />
        <Button Content="Add Job" VerticalAlignment="Top" Grid.Column="1" Margin="155,10,0,0"
        	Command="{Binding AddJobClickAction}" HorizontalAlignment="Left" Width="58"  />
        <Label Content="Change Name" Grid.Column="1" HorizontalAlignment="Left" Margin="218,8,0,0" VerticalAlignment="Top"  Width="85" />
        <Label Content="Quality" HorizontalAlignment="Left" Margin="31,41,0,0" VerticalAlignment="Top"/>

        <xctk:DecimalUpDown Value="{Binding SelectedJob.Quality, UpdateSourceTrigger=PropertyChanged}" Minimum="0" Maximum="100" Margin="0,47,0,0" HorizontalAlignment="Left" Width="78"  VerticalAlignment="Top" Grid.Column="1" RenderTransformOrigin="0.769,-1.875" />
        <Label Content="%" Grid.Column="1" HorizontalAlignment="Left" Margin="83,43,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.053,0.321"/>
        <Button Content="Remove Job" VerticalAlignment="Top" Grid.Column="1" Margin="420,8,0,0"
        	Command="{Binding RemoveJobClickAction}" HorizontalAlignment="Left"   />

    </Grid>
</UserControl>